From: Lukáš Tyrychtr Date: Wed, 14 Sep 2022 14:53:04 +0000 (+0200) Subject: Account for GtkAccessibleRange implementations which do not have a X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~116^2~1^2~202^2~11 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=86864d7bc063ad69474d845e21f50c1705ddf04a;p=gtk4.git Account for GtkAccessibleRange implementations which do not have a minimum step and it makes no sense for them to set the current value --- diff --git a/gtk/gtkaccessiblerange.c b/gtk/gtkaccessiblerange.c index 555e1eb921..363e954515 100644 --- a/gtk/gtkaccessiblerange.c +++ b/gtk/gtkaccessiblerange.c @@ -40,9 +40,23 @@ G_DEFINE_INTERFACE (GtkAccessibleRange, gtk_accessible_range, GTK_TYPE_ACCESSIBLE) +static double +gtk_accessible_range_default_get_minimum_increment (GtkAccessibleRange *accessible_range) +{ + return 0.0; +} + +static void +gtk_accessible_range_default_set_current_value (GtkAccessibleRange *accessible_range, double value) +{ + /* By default, we do nothing */ +} + static void gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface) { + iface->get_minimum_increment = gtk_accessible_range_default_get_minimum_increment; + iface->set_current_value = gtk_accessible_range_default_set_current_value; } /* @@ -51,7 +65,7 @@ gtk_accessible_range_default_init (GtkAccessibleRangeInterface *iface) * * Returns the minimum increment which this `GtkAccessibleRange` supports. * - * Returns: the minimum increment + * Returns: the minimum increment, or 0.0 if not overridden */ double gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self) @@ -66,11 +80,15 @@ gtk_accessible_range_get_minimum_increment (GtkAccessibleRange *self) * @self: a `GtkAccessibleRange` * * Sets the current value of this `GtkAccessibleRange`. + * Note that for some widgets implementing this interface, setting a value + * through the accessibility API makes no sense, so calling this function may + * in some cases do nothing. */ void gtk_accessible_range_set_current_value (GtkAccessibleRange *self, double value) { g_return_if_fail (GTK_IS_ACCESSIBLE_RANGE (self)); - return GTK_ACCESSIBLE_RANGE_GET_IFACE (self)->set_current_value (self, value); + GtkAccessibleRangeInterface *iface = GTK_ACCESSIBLE_RANGE_GET_IFACE (self); + iface->set_current_value (self, value); } \ No newline at end of file